package com.vlada.studzad.pages;

import java.text.Format;
import java.util.ArrayList;
import java.util.List;

import org.apache.tapestry5.annotations.ApplicationState;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.grid.GridDataSource;

import com.vlada.studzad.data.MockDataEmployerSource;
import com.vlada.studzad.model.Privilege;
import com.vlada.studzad.model.Student;
import com.vlada.studzad.model.User;
import com.vlada.studzad.model.Employer;
import com.vlada.studzad.util.EmployerSource;

public class PreviewEmployersProfiles {
	
	@ApplicationState
	@Property
	private User user;
	private boolean userExists;	
	@ApplicationState
	private MockDataEmployerSource employers;
	private Employer employer;
	
	Object onActivate() {
		if (!userExists)return Index.class;
		else if(user.getPrivilege()==Privilege.ADMINISTRATOR){
			return null;
		}
		return Index.class;
	}
	
	public List<Employer> getAllEmployers() {
		return employers.getAllEmployers();
	}
	
	public void setEmployer(Employer employer) {
		this.employer = employer;
	}

	public Employer getEmployer(){
		return employer;
	}

	public GridDataSource getEmployerSource() {
		return new EmployerSource(employers);
	}
	
}
